package br.org.etec.dotcao.service;

import br.org.etec.dotcao.mailer.MailerExecutor;
import br.org.etec.dotcao.mailer.Receiver;
import br.org.etec.dotcao.mailer.Sender;

public class MailService {
	
	private Sender sender;
	private Receiver receiver;
	private String content;
	private String subject;
	
	public MailService receiver(Receiver receiver) {
		this.receiver = receiver;
		return this;
	}
	
	public MailService sender(Sender sender) {
		this.sender = sender;
		return this;
	}
	
	public MailService content(String content) {
		this.content = content;
		return this;
	}
	
	public MailService subject(String subject) {
		this.subject = subject;
		return this;
	}
	
	public void send(){
		MailerExecutor executor = new MailerExecutor();
		executor.setSender(sender);
		executor.setReceiver(receiver);
		executor.setNumberOfThreads(1);
		executor.setCharset("ISO-8859-1");
		executor.setFileContent(content);
		executor.setSubject(subject);
		
		try {
			executor.execute();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
